<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/_fragments :: head(~{::title})">
    <title>新增分类</title>
</head>
<body>
<!--导航条-->
<nav th:replace="admin/_fragments :: menu(2)"></nav>
<div class="ui menu attached pointing m-bg animated fadeInDown">
    <div class="ui container">
        <div class="right mini menu">
            <a th:href="@{/admin/types/input}" class="item  active m-pink">发布</a>
            <a th:href="@{/admin/types}" class="item  m-pink">列表</a>
        </div>
    </div>
</div>
<!--中间内容-->
<div class="m-container-large m-padded-tb-big m-bg">
    <div class="ui container m-bg">
        <form method="post" th:object="${type}" th:action="*{id}==null ? @{/admin/types} : @{/admin/types/{id}(id=*{id})}" class="ui form">
            <input type="hidden" name="id" th:value="*{id}">
            <div class="field">
                <div class="ui left input labeled">
                    <label class="ui teal basic label">名称</label>
                    <input type="text" name="name" placeholder="分类名称" th:value="*{name}">
                </div>
            </div>
            <div class="ui error mini message"></div>
            <!--/*/
             <div class="ui negative message" th:if="${#fields.hasErrors('name')}"  >
                <i class="close icon"></i>
                <div class="header">验证失败</div>
                <p th:errors="*{name}">提交信息不符合规则</p>
            </div>
            /*/-->
            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button class="ui teal submit button">提交</button>
            </div>
        </form>
    </div>
</div>
<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
<!--/*/</th:block>/*/-->
</body>
</html>
<script>
    <!-- 移动端导航条   -->
    $(".toggle.menu").click(function () {
        $(".m-item").toggleClass("m-mobile-hide")
    })
    $(".ui.dropdown").dropdown({
        on: 'hover'
    });
    // 表单验证
    $(".ui.form").form({
        fields: {
            name: {
                identifier: 'name',
                rules: [{
                    type: 'empty',
                    prompt: '分类：请输入分类名称'
                }]
            }
        }
    });
    $(".message .close").on('click',function () {
        $(this).closest(".message")
            .transition("fade");
    })
</script>